#!/bin/bash
source $DRAW_INI
source $DRAW_CFG

#mkdir -p ../csv

NAME=$(basename $1)
RFILE="../csv/$NAME.indel.recal"
TFILE="../csv/$NAME.indel.tranches"


java -Xmx3g -jar $GATK \
  -T ApplyRecalibration \
  -R $REF_FASTA \
	--ts_filter_level 95.0 \
   -mode INDEL \
    -recalFile $RFILE \
   -tranchesFile $TFILE \
  -input $1.vcf \
  -o $1.recal.indel.vcf
     
EXITSTATUS=$?

#force error when missing recalFile. Would prevent continutation of pipeline
if [[ ! -s "$1.recal.indel.vcf" ]];
then
 echo "Missing $RFILE or $TFILE in ../csv" 
 exit 100
fi

exit $EXITSTATUS
